package algotithm.jianzhioffer.test21;

/**
 * @author zhouyanxiang
 * @Date 2020-12-2020/12/19-23:20
 */
public class Solution {

    public static void main(String[] args) {
        int[] arr = {1, 20, 22, 13, 18, 19, 0, 2, 3, 66};
        Solution solution = new Solution();
        int[] num = solution.exchange(arr);
        for (int i = 0; i < num.length; i++) {
            System.out.print(num[i] + " ");
        }
    }

    public int[] exchange(int[] nums) {
        int p = 0;
        int len = nums.length;
        for (int i = 0; i < len; i++) {
            if ((nums[i] & 1) == 1) {
                int tmp = nums[i];
                nums[i] = nums[p];
                nums[p++] = tmp;
            }
        }
        return nums;
    }

}
